package com.javaeye.dengyin2000.gwtmodel.client.model;

import com.javaeye.dengyin2000.gwtmodel.client.exceptions.GWTModelRuntimeException;
import com.javaeye.dengyin2000.gwtmodel.client.utils.PropertyUtils;


public class PropertyModel implements IModel {
	
	private Object object;
	private String expression;
	
	public PropertyModel(Object object, String expression) {
		this.object = object;
		this.expression = expression;
	}
	
	public Object getObject() {
		try {
			return PropertyUtils.getProperty(object, expression);
		} catch (Exception e){
			throw new GWTModelRuntimeException(e);
		}
	}

	public void setObject(Object value) {
		try {
			PropertyUtils.setProperty(object, expression, value);
		} catch (Exception e){
			throw new GWTModelRuntimeException(e);
		}
	}

}
